package com.doradance.account.utils;

import android.content.Context;

import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

/**
 * Created by Administrator on 2017/6/16.
 */

public class WechatHelper {


    public static final String WECHAT_APP_ID = "wx973f6a5763d59a3a";


    private WechatHelper() {
    }

    private static WechatHelper instance;


    public static WechatHelper getInstance() {
        if (instance == null) {
            synchronized (WechatHelper.class) {
                instance = new WechatHelper();
            }
        }
        return instance;
    }

    private IWXAPI wechatApi;

    public IWXAPI init(Context context) {
        wechatApi = WXAPIFactory.createWXAPI(context, WECHAT_APP_ID, true);
        wechatApi.registerApp(WECHAT_APP_ID);
        return wechatApi;
    }




    public void sendAuthWechat() {
        //登录微信
        final SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo";
        req.state = "wechat_sdk_demo_test";
        wechatApi.sendReq(req);
    }


}
